﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TrackSystem.Entities.Extensions
{
    public class FormatChecker
    {
        private const string PatternIP = @"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
        private const string PatternSerialParams = @"[E|O|N|]-[8|7]-[0|1|H]";

        public static bool IsValidIP(string? ip)
        {
            if (string.IsNullOrEmpty(ip)) return false;
            return System.Text.RegularExpressions.Regex.IsMatch(ip, PatternIP);
        }

        public static bool IsValidSerialParams(string? s)
        {
            if (string.IsNullOrEmpty(s)) return false;
            return System.Text.RegularExpressions.Regex.IsMatch(s, PatternSerialParams);
        }
    }
}
